<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Data_ArrayIterator
 *
 * @author ananda
 */
class Data_ArrayIterator extends Data_Collection
{
    protected $handler;

    public function __construct($handler, $params = array()) {
        $this->handler = $handler;
        foreach ($params as $key => $value) {
            $this->$key = $value;
        }
        $this->init();
    }

    public function init()
    {
    }

    public function rowCount()
    {
        return count($this->handler);
    }

    public function getArray()
    {
        return $this->handler;
    }

    public function getKeys()
    {
        return array_keys($this->handler);
    }

    /**
     * 迭代器接口
     * @return mixed
     */
    public function current()
    {
        return $this->handler[$this->cursor];
    }

    /**
     * 迭代器接口
     * @return mixed
     */
    public function key()
    {
        return $this->cursor;
    }

    /**
     * 迭代器接口
     * @return void
     */
    public function next()
    {
        $this->cursor++;
    }

    /**
     * 迭代器接口
     * @return void
     */
    public function rewind()
    {
        $this->cursor = 0;
    }

    /**
     * 迭代器接口
     * @return boolean
     */
    public function valid()
    {
        return $this->cursor !== false && isset($this->handler[$this->cursor]);
    }

}
